package test2;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入密码：");
        String pwd = sc.next();
        if (pwd ==null){//判断密码是否为空
            System.err.println("密码不能为空");
            return;
        }
        System.out.println("原始密码为："+pwd);
        //循环加密后
        //获取字符串转为字符数组
        char[] chars = pwd.toCharArray();
        System.out.println("\n加密后的密码为：");
        for (int i = 0; i < chars.length; i++) {
            //将取到的字符转换为数字+5
            chars[i] = (char)(chars[i]+5);
            System.out.print(chars[i]);
        }
        System.out.println("解密后的密码为：");
        for (int i = 0; i < chars.length; i++) {
            //将取到的字符转换为数字+5
            chars[i] = (char)(chars[i]-5);
            System.out.print(chars[i]);
        }

    }
}
